﻿
@{
    ViewBag.Title = "BudgetNotificationAdd";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css {
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <style>
        th {
            text-align: center;
            font-weight: bold;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}
<div class="page-content" ng-cloak ng-controller="SafetyOrganizationController" ng-init="SearchModel = {};
     page='@(Request.QueryString["page"].IsEmpty() ? "1" : Request.QueryString["page"])';
     GetOrganizationPageList(SearchModel,page);
    ">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
			</path>
		</svg>
            <div class="load-msg" ng-bind="LoadingMsg"></div>
        </div>
    </div>
    <div class="page-heading">
        <h1>组织管理</h1>
        <div class="options">
            <div class="btn-toolbar">

            </div>
        </div>
    </div>

    <ol class="breadcrumb">
        <li><a>主页</a></li>
        <li><a>组织结构</a></li>
        <li class="active"><a>组织管理</a></li>
    </ol>

    <div class="container-fluid">
        <div class="row">
            <form class="form-horizontal row-border">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading"><h2>筛选条件</h2></div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">名称：</label>
                                <div class="col-sm-2">
                                    <input type="text" class="form-control" ng-model="SearchModel.Name" />
                                </div>
                                <button class="btn btn-primary" ng-click="GetOrganizationPageList(SearchModel,1);">查询</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div id="step"></div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="panel panel-sky">
                    <div class="panel-heading">
                        <h2>组织数量 总数：<b ng-bind="TotalCount"></b></h2>
                        <div class="panel-ctrls">
                            <div class="btn-group">
                                <a ng-click="GetOrganizationList();" class="btn btn-primary btn-sm" href="#AddModal" data-toggle="modal"><i class="fa fa-plus"></i> 添加组织</a>
                            </div>
                        </div>
                    </div>
                    <div class="panel-body">
                        <table class="table table-striped table-bordered table-hover" ng-show="!PageLoading">
                            <thead>
                                <tr style="background-color:blueviolet;">
                                    <th style="width:2%">序号</th>
                                    <th style="width:10%">组织名称</th>
                                    <th style="width:10%">人员</th>
                                    <th style="width:5%">排序</th>
                                    <th style="width:15%">上级组织</th>
                                    <th style="width:5%">创建日期</th>
                                    <th style="width:5%">创建人</th>
                                    <th style="width:15%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-show="DataList.length==0 && !DataLoading">
                                    <td colspan="12" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                </tr>
                                <tr ng-repeat="x in DataList">
                                    <td>{{$index+1}}</td>
                                    <td>{{x.NodeName}}</td>
                                    <td><a ng-click="GetCurrentModel(x);" data-toggle="modal" href="#EmpModal">{{x.EmpList.length}}</a></td>
                                    <td>{{x.SortBy}}</td>
                                    <td>{{x.ParentName}}</td>
                                    <td>{{x.CreateTime|JSONDate:'yyyy-MM-dd HH:mm'}}</td>
                                    <td>{{x.CreateUserName}}</td>
                                    <td>
                                        <a ng-show="@ViewBag.IsModify==1" ng-click="GetAllUserList('u_list');GetCurrentModel(x);EmpModel={};" data-toggle="modal" href="#SetEmpModal" class="btn btn-success btn-xs btn-label"><i class="fa fa-trash"></i>设置人员</a>
                                        <a ng-show="@ViewBag.IsModify==1" ng-click="GetOrganizationList();GetCurrentModel(x);" data-toggle="modal" href="#EditModal" class="btn btn-warning btn-xs btn-label"><i class="fa fa-trash"></i>编辑</a>
                                        <a ng-show="@ViewBag.IsDelete==1" ng-click="DeleteSafetyCase(x.Id,SearchModel,result.currentPage);" class="btn btn-danger btn-xs btn-label"><i class="fa fa-trash"></i>删除</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="text-center" ng-show="DataList!=null && DataList.length>0">
                    <ul class="pagination  justify-content-center">
                        <li class="page-item"><a class="page-link" style="cursor:pointer;" ng-click="GetOrganizationPageList(SearchModel,1);">首页</a></li>
                        <li class="page-item" ng-class="{'active':result.currentPage==page}" ng-repeat="page in result.pages"><a style="cursor:pointer;" ng-click="GetSafetyCasePageList(SearchModel,page)" class="page-link" ng-bind="page"></a></li>
                        <li class="page-item"><a class="page-link" style="cursor:pointer;" ng-click="GetOrganizationPageList(SearchModel,(result.currentPage + 1 > result.totalPage ? result.totalPage : result.currentPage + 1))">下一页</a></li>
                        <li class="page-item"><a class="page-link" style="cursor:pointer;" ng-click="GetOrganizationPageList(SearchModel,result.totalPage);">尾页</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="AddModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">添加组织机构</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal row-border">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">组织名称：</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" ng-model="AddModel.NodeName" />
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上级节点：</label>
                            <div class="col-sm-5">
                                <select class="form-control" ng-model="AddModel.ParentNode">
                                    <option value=""></option>
                                    <option ng-repeat="x in OrgList" value="{{x.Id}}">{{x.NodeName}}</option>
                                </select>
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">显示顺序：</label>
                            <div class="col-sm-5">
                                <input type="number" class="form-control" ng-model="AddModel.SortBy" ng-init="AddModel.SortBy=0" />
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="AddOrganization(AddModel,SearchModel,result.currentPage);">提交</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="SetEmpModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">设置组织人员</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal row-border">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">选择人员：</label>
                            <div class="col-sm-5">
                                <select id="u_list" class="selectpicker show-tick form-control" ng-model="EmpModel.UserNo" ng-change="refreshOption('u_list');" data-live-search="true">
                                </select>
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">职位名称：</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" ng-model="EmpModel.Title" />
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">显示次序：</label>
                            <div class="col-sm-5">
                                <input type="number" class="form-control" ng-model="EmpModel.SortBy" ng-init="EmpModel.SortBy=0" />
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close5">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="AddOrgEmp(EmpModel,CurrentModel,SearchModel,result.currentPage);">提交</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="EditModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">编辑组织机构</h2>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal row-border">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">组织名称：</label>
                            <div class="col-sm-5">
                                <input type="text" class="form-control" ng-model="CurrentModel.NodeName" />
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">上级节点：</label>
                            <div class="col-sm-5">
                                <select class="form-control" ng-model="CurrentModel.ParentNode">
                                    <option value="">根节点</option>
                                    <option ng-repeat="x in OrgList" value="{{x.Id}}">{{x.NodeName}}</option>
                                </select>
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">显示顺序：</label>
                            <div class="col-sm-5">
                                <input type="number" class="form-control" ng-model="CurrentModel.SortBy" ng-init="AddModel.SortBy=0" />
                            </div>
                            <label class="col-sm-2 control-label" style="color:red;text-align:left;font-weight:bold;">*</label>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close_1">关闭</button>
                    <button type="button" class="btn btn-primary" ng-click="EditOrganization(CurrentModel,SearchModel,result.currentPage);">提交</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="EmpModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:985px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">组织人员</h2>
                </div>
                <div class="modal-body">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th>序号</th>
                                <th>人员</th>
                                <th>职务</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr ng-show="CurrentModel.EmpList.length==0">
                                <td colspan="3">
                                  暂未绑定人员
                                </td>
                            </tr>
                            <tr ng-show="CurrentModel.EmpList.length>0" ng-repeat="x in CurrentModel.EmpList">
                                <td>
                                    {{$index+1}}
                                </td>
                                <td>
                                    {{x.UserName}}
                                </td>
                                <td>
                                    {{x.Title}}
                                </td>
                                <td>
                                    <a ng-show="@ViewBag.IsDelete==1" ng-click="" class="btn btn-danger btn-xs btn-label"><i class="fa fa-trash"></i>删除</a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close_1">关闭</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>
@section Js{
    <script src="~/Assets/plugins/form-ckeditor/ckeditor.js"></script>
    <script src="~/Assets/js/libs/upload.js"></script>
    <script src="~/Assets/js/pg/SafetyOrganization.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/Assets/js/libs/moment.min.js"></script>
    <script src="~/Assets/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/Assets/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Assets/js/libs/angularjs-datepicker.js"></script>
    <script src="~/Assets/js/libs/fileinput.js"></script>
    <script src="~/Assets/js/libs/zh.js"></script>
    <script>
        $('#SelectedCheckList').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });

        $("#u_list").selectpicker({
            noneSelectedText: "选择人员信息"
        });
    </script>
}
